import fs, {PathOrFileDescriptor} from "fs";
import yaml from "js-yaml";

export function readAndParseYAML(path: PathOrFileDescriptor,): any {
    let config: any;

    try {
        // 读取 YAML 文件内容
        const yamlContent = fs.readFileSync(path, 'utf8');

        // 解析 YAML
        config = yaml.load(yamlContent);


    } catch (error) {
        if (error instanceof Error) {
            console.error('Error reading or parsing YAML file:', error.message);
        } else {
            console.error('Unexpected error:', error);
        }
    }

    return config;
}